﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity;
using System.IO;
using System.ComponentModel.DataAnnotations.Schema;

namespace Happy.Domain.EntityFramework.Test.Stub
{
    public sealed class TestUnitOfWork : UnitOfWork
    {
        public TestUnitOfWork()
            : base(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=" + System.Environment.CurrentDirectory + @"\App_Data\EntityFrameworkDatabase.mdf;Integrated Security=True;Connect Timeout=30")
        {
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<User>()
                .HasKey(x => x.Id);
            modelBuilder.Entity<User>()
                .Property(x => x.OptimisticKey)
                .IsConcurrencyToken();
            base.OnModelCreating(modelBuilder);
        }
    }
}
